1. Field of the Invention
The present invention relates to disk drive performance features and more particularly to a disk drive having a cache control technique for caching both streaming and non-streaming data.
2. Description of the Prior Art
A host computer stores and accesses data on a disk drive by issuing commands to the disk drive over a standardized interface. The smallest indivisible data unit addressable on a disk is a disk sector or logical block which has an assigned logical block address (LBA). Existing disk drives typically have a semiconductor cache memory for temporarily storing disk data that is likely to be requested by a host computer. The semiconductor memory greatly enhances the performance of the disk drive because the semiconductor memory has a response time latency for storing and accessing data that is a much smaller than the response time latency for mechanically storing and accessing data stored on a rotating disk.
The nature of data stored in a disk drive may be generally defined as streaming data and non-streaming data. Streaming data is often associated with continuous audio and/or full-motion video data for live or real-time presentation to an audience. Non-streaming data is often associated with blocks of text data, numeric data and program control code. In order to provide a competitive product, a disk drive must provide high performance in an environment when both streaming and non-streaming data are accessed.
Accordingly, there exists a need for a disk drive having a disk data cache memory for effectively and efficiently responding to host commands for both streaming and non-streaming data. The present invention satisfies these needs.
The present invention is embodied in a method, and related apparatus, for caching disk data in a disk drive configured to receive commands for both streaming and non-streaming data from a host. In the method, a memory segment is provided for caching disk data associated with a logical block address range and a plurality of data blocks are cached in the memory segment. A lossy state record is provided for the memory segment. The lossy state record is set to be true if one of the plurality of data blocks in the memory segment contains a data error and is set to be false if no data error is in the cached data blocks. A host command specifying a commanded logical block address range is received and compared with the logical block address range cached in the memory segment to determine whether the commanded logical block address range overlaps the cached logical block address range. If the host command is for streaming data and the lossy state record is true, the cached data blocks of the overlapping commanded logical block address range, including the block containing the data error, are transferred to the host. Otherwise, if the host command is for non-streaming data, the lossy state record is checked and if the lossy state record is false, the cached data blocks of the overlapping commanded logical block address range are transferred to the host.
Also, for non-streaming data, the lossy state record may be checked and if the lossy state record is true, a subset of the cached data blocks may be transferred to the host. The subset may be the cached data blocks preceding the data block having an error. Further, a disk operation may be scheduled to recover the data block having an error.
Additionally, the host command may be a mode-change host command in that the host command is for streaming data following a previous command for non-streaming data or the host command is for non-streaming data following a previous command for streaming data. The plurality of data blocks may remain cached in the memory segment for the mode-change host command.